const { View , Text , Button} = require("@tarojs/components");
import './AccomplishPhysical.less'
import http from '../../../../utils/http'
import Taro,{useReady} from '@tarojs/taro'
import React, { useState} from 'react'

// 已体检

function AccomplishPhysical () {

    const [index,setIndex]=useState('')
    const [sum,setSum]=useState()
    const [id,setId]=useState('')
    const [arr,setArr]=useState({})

    let look = (b) => {
        Taro.navigateTo({
            url:'/pages/HXM/LookReport/LookReport?id='+b
        })
    }

    useReady(() => {
        setId(Taro.getCurrentInstance().router.params.id)
        setIndex(Taro.getCurrentInstance().router.params.index)
        http({   //获取我的体检详细
            url:"/getaccomplishphysical",
            data:{
                order_orderId:Taro.getCurrentInstance().router.params.id
            },
            header:{
                'content-type': 'application/json' 
            },
        }).then((res)=>{
            setArr(res[0])
            setSum(res[0].contentPrice+res[0].phy_salePrice)
        })
      })

    return(
        <View>
            <View>
                <View className="view1" >
                    <View className="view1-1">
                        <Text>{arr.user_name} {arr.user_tel}</Text>
                    </View>
                    <View className="view1-2">
                        <View>
                            体检机构: <Text> {arr.org_Name}</Text>
                        </View>
                        <View>
                            体检时间: <Text> {arr.order_date}</Text>
                        </View>
                        <View>
                            体检单号: <Text> {arr.productId}</Text>
                        </View>
                    </View>
                </View>
                <View className="view2">
                    <View className="view2-1">
                        <Text>订单编号：{arr.order_orderId}</Text>
                    </View>
                    <View className="view2-2">
                        <View>
                            <Text>{arr.order_orderId}</Text>
                            <Text>￥{arr.contentPrice}</Text>
                        </View>
                        <View>
                            <Text>{arr.phy_projectName}</Text>
                            <Text>￥{arr.phy_salePrice}</Text>
                        </View>
                        <View>
                            <Text style="color:red">合计</Text>
                            <Text style="color:red">￥{sum}</Text>
                        </View>
                    </View>
                </View>
                <View className="view3">
                    <Button type="primary" plain="true" onClick={look.bind(this,id)}>查看体检报告</Button>
                </View>
            </View>
        </View>
    )
}

export default AccomplishPhysical